#!/bin/sh /etc/rc.common


START=10
USE_PROCD=1
DESC="MT7621 GPIO Control Service"

#校验参数的函数
validate_idc_app_section() {
        uci_validate_section idc_app conf "${1}" \
                'lte_enable:string'\
                'iot_enable:string'\
                'is_center:string'\
                'bridge_enable:string'\
                'mesh_enable:string'
}
#启动函数
start_service() {
        procd_open_instance
        procd_set_param command /bin/true
        procd_set_param respawn
        procd_set_param stdout 1
        procd_set_param stderr 1
        procd_close_instance
    
        echo "Starting GPIO Control Service"
    
        # 等待内核模块加载
        sleep 2
    
        # 检查设备是否存在
        if [ ! -c /dev/gpio-control ]; then
                echo "Error: GPIO control device not found"
                return 1
        fi
    
        # 初始化GPIO状态
        /usr/bin/gpio-control init
    
        echo "GPIO Control Service started successfully"
}
#停止函数
stop_service()
{
        echo "Stopping GPIO Control Service"
    
        # 设置GPIO为安全状态（低电平）
        /usr/bin/gpio-control low
    
        echo "GPIO Control Service stopped"
}

restart_service() {
        stop_service
        sleep 1
        start_service
}

reload_service() {
        restart_service
}

service_triggers() {
        procd_add_reload_trigger gpio
}
